<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <template id="sonTemp"> 
        <div id="header" class="my" style="background-color: hotpink;">
            子组件
            <input :type="$attrs.type">
        </div>
    </template>

    <script>
        const son = {
            template:'#sonTemp',
            created() {
                console.log(this.$attrs.id);
            },
        }
    </script>

    <div id='app'>
        <div id="div1"></div>
        <!-- 父组件传递的属性，会直接加载子组件根标签上，如果之前有的话会覆盖
        class和style不会覆盖，会合并
        在子组件中可以通过$attrs拿到父组件传递的属性 -->
        <son id="son" type="password" class="son" style="color: lawngreen;"></son>
        <!-- <son id="son" class="son" style="color: lawngreen;"></son> -->
    </div>

    <script>
        const vm = new Vue({
            el: '#app',
            data: {},
            components:{
                son
            }
        })

        function Animal(){

        }

        const bird  = new Animal()
        const cat = new Animal()
    </script>
</body>

</html>